//
//  DCDetailGoodReferralCell.m
//  商城
//
//  Created by runone02 on 2018/8/27.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "DCDetailGoodReferralCell.h"
#import "DCUpDownButton.h"


@interface DCDetailGoodReferralCell ()

/* 自营 */
@property (strong , nonatomic)UIImageView *autotrophyImageView;
/* 分享按钮 */
@property (strong , nonatomic)DCUpDownButton *shareButton;

@end

@implementation DCDetailGoodReferralCell

#pragma mark - Intial
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpUI];
    }
    return self;
}

#pragma mark - UI
- (void)setUpUI{
    self.backgroundColor = [UIColor whiteColor];
    
    _autotrophyImageView = [[UIImageView alloc] init];
    [self addSubview:_autotrophyImageView];
    _autotrophyImageView.image = IMAGE(@"detail_title_ziying_tag");
    
    _goodTitleLabel = [[UILabel alloc] init];
    _goodTitleLabel.font = TITLE_FONT(26);
    _goodTitleLabel.numberOfLines = 0;
    [self addSubview:_goodTitleLabel];
    
    _goodPriceLabel = [[UILabel alloc] init];
    _goodPriceLabel.font = TITLE_FONT(24);
    _goodPriceLabel.textColor = [UIColor redColor];
    [self addSubview:_goodPriceLabel];
    
    _goodSubtitleLabel = [[UILabel alloc] init];
    _goodSubtitleLabel.font = TITLE_FONT(24);
    _goodSubtitleLabel.numberOfLines = 0;
    _goodSubtitleLabel.textColor = RGB(233, 35, 46);
    [self addSubview:_goodSubtitleLabel];
    
    _shareButton = [DCUpDownButton buttonWithType:UIButtonTypeCustom];
    [_shareButton setTitle:@"分享" forState:0];
    [_shareButton setImage:IMAGE(@"icon_fenxiang2") forState:0];
    [_shareButton setTitleColor:[UIColor blackColor] forState:0];
    _shareButton.titleLabel.font = TITLE_FONT(20);
    [self addSubview:_shareButton];
    [_shareButton addTarget:self action:@selector(shareButtonClick) forControlEvents:UIControlEventTouchUpInside];
    
    [DCSpeedy dc_setUpAcrossPartingLineWith:self WithColor:[[UIColor lightGrayColor]colorWithAlphaComponent:0.15]];
}

#pragma mark - 布局
- (void)layoutSubviews{
    [super layoutSubviews];
    WEAKSELF
    [_autotrophyImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self).with.offset(W_RATIO(10));
        make.top.mas_equalTo(self).with.offset(W_RATIO(20));
        make.size.mas_equalTo(weakSelf.autotrophyImageView.image.size);
    }];
    
    [_shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self).with.offset(-5);
        [make.top.mas_equalTo(self)setOffset:DCMargin];
        make.width.mas_equalTo(W_RATIO(40));
    }];
    
    [_goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.autotrophyImageView.mas_right);
        make.right.mas_equalTo(weakSelf.shareButton.mas_left).with.offset(-W_RATIO(5));
        make.top.mas_equalTo(weakSelf.autotrophyImageView).with.offset(-3);
    }];

    
    [_goodSubtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.autotrophyImageView);
        make.top.mas_equalTo(weakSelf.goodTitleLabel.mas_bottom).with.offset(W_RATIO(15));
        make.right.mas_equalTo(weakSelf.goodTitleLabel);
    }];
    
    [_goodPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.autotrophyImageView);
        make.top.mas_equalTo(weakSelf.goodSubtitleLabel.mas_bottom).with.offset(W_RATIO(15));
    }];

}


#pragma mark - 分享按钮点击
- (void)shareButtonClick{
    !_shareButtonClickBlock ? : _shareButtonClickBlock();
}

#pragma mark - Setter Getter Methods


@end
